import { Get, Post } from "@/utils/request";
/**
 * 登录
 * @param params
 * @returns
 */
export function loginAccount(params) {
  return Post("/v1/login", params, {
    loading: true,
  });
}

export function logout() {
  return Post("/v1/logout", {}, { loading: true });
}

export function modifyPassword(params) {
  return Post("/v1/changePassword", params, { loading: true });
}

export function reformCount() {
  return Get("/v1/applet/reforms/reformCount");
}
/**
 * 整改点位列表
 * @param is_reform
 * @param page
 * @returns
 */
export function reformPointList(is_reform: number, page: number) {
  return Get("/v1/applet/reforms/reformPointList", {
    is_reform: is_reform,
    page: page,
    limit: 20,
  });
}
/**
 * 整改点位问题列表
 *
 */
export function reformPointProblemList(
  point_id: number,
  is_reform: number,
  page: number
) {
  return Get("/v1/applet/reforms/reformPointProblemList", {
    is_reform: is_reform,
    page: page,
    limit: 20,
    point_id: point_id,
  });
}
/**
 * 整改问题详情
 */
export function questionDetail(problemId: number) {
  return Get("/v1/applet/problems/" + problemId);
}
/**
 *
 * 网格点位列表
 */
export function gridPaginateList(
  page: number,
  point_name?: string,
  region_id?: number
) {
  return Get(
    "/v1/applet/grids/gridPaginateList?page=" +
      page +
      "&&point_name=" +
      point_name +
      "&&region_id=" +
      region_id
  );
}
/**
 * 网格点位列表
 * @param grid_id
 * @param point_name
 * @returns
 */
export function gridPointList(grid_id: number, point_name?: string) {
  return Get(
    "/v1/applet/grids/gridPointList?grid_id=" + grid_id + "&&point_name=" + ""
  );
}
/**
 * 点位详情
 * @param point 点位ID
 * @returns
 */
export function pointDetail(point: number) {
  return Get("/v1/applet/points/" + point);
}
/**
 *
 * @param point 督查列表
 * @param page
 * @returns
 */
export function pointDoRecordList(point: number, page: number) {
  return Get(
    "/v1/applet/points/pointDoRecordList?page=" + page + "&&point_id=" + point
  );
}
/**
 * 督查问题列表
 */
export function pointDoProblemList(
  point_id: number,
  do_user_id: number,
  done_date: string,
  page: number,
  is_big_than_zero: number
) {
  return Get(
    "/v1/applet/points/pointDoProblemList?page=" +
      page +
      "&&point_id=" +
      point_id +
      "&&do_user_id=" +
      do_user_id +
      "&&done_date=" +
      done_date +
      "&&limit=10&&is_big_than_zero=" +
      is_big_than_zero
  );
}
/**
 * 用户今日执行任务列表
 * @param do_user_id 用户ID
 * @param page
 * @returns
 */
export function userTodayDoTaskList(do_user_id: number, page: number) {
  return Get(
    "/v1/applet/users/userTodayDoTaskList?page=" +
      page +
      "&&do_user_id=" +
      do_user_id +
      "&&limit=10"
  );
}
/**
 * 用户今日执行问题列表
 * @param do_user_id
 * @param task_id
 * @param page
 * @returns
 */
export function userDoTaskProblemList(
  do_user_id: number,
  task_id: number,
  page: number
) {
  return Get(
    "/v1/applet/users/userDoTaskProblemList?page=" +
      page +
      "&&do_user_id=" +
      do_user_id +
      "&&limit=10" +
      "&&task_id=" +
      task_id
  );
}
/**
 * 问题账台列表
 * @param page
 * @returns
 */
export function regionData() {
  return Get("/v1/applet/statistics/regionData");
}
/**
 * 某区网格
 * @param region_id
 * @returns
 */
export function regionGridData(region_id: number) {
  return Get("/v1/applet/statistics/regionGridData?region_id=" + region_id);
}

/**
 * 单个点位问题列表统计
 * @param point_id
 * @param is_reform
 * @returns
 */
export function singlePointProblemList(
  point_id: number,
  is_reform: number,
  page: number
) {
  return Get(
    "/v1/applet/statistics/singlePointProblemList?point_id=" +
      point_id +
      "&&is_reform=" +
      is_reform +
      "&&page=" +
      page
  );
}
/**
 * 获取 城市
 * @returns
 */
export function getCitys() {
  return Get("/v1/cities");
}
export function gridFenceList() {
  return Get("/v1/applet/grids/gridFenceList");
}
/**
 * 区县地图用户数据
 */
export function regionUserEntityList(region_id?: number) {
  return Get("/v1/applet/users/userEntityList?region_id=" + region_id);
}
export function allUserEntityList() {
  return Get("/v1/applet/users/userEntityList");
}
/**
 * 用户每日执行点位
 * @param do_user_id
 * @param done_date
 * @returns
 */
export function userDoPointPaginateList(
  do_user_id: number,
  done_date: string,
  page: number
) {
  return Get(
    "/v1/applet/users/userDoPointPaginateList?do_user_id=" +
      do_user_id +
      "&&done_date=" +
      done_date +
      "&&page=" +
      page
  );
}
export function delayReformProblem(reform_id: number, delay_days: string) {
  return Post(
    "/v1/applet/reforms/delayReformProblem",
    {
      reform_id: reform_id,
      delay_days: delay_days,
    },
    {
      loading: true,
      toast: true,
    }
  );
}
export function singleGridCount(grid_id: number) {
  return Get("/v1/applet/statistics/singleGridCount?grid_id=" + grid_id);
}
export function singleGridProblemPointList(grid_id: number, page: number) {
  return Get(
    "/v1/applet/statistics/singleGridProblemPointList?grid_id=" +
      grid_id +
      "&&page=" +
      page
  );
}
/**
 * 关键数据统计
 */
export function getKeyData() {
  return Get("/v1/applet/statistics/keyData");
}
/**
 * 发现问题总数
 *
 */
export function findQuestionCount() {
  return Get("/v1/applet/statistics/discoverProblemCount");
}
/**
 *
 * @returns 网格整改率
 */
export function gridReformProblemCount() {
  return Get("/v1/applet/statistics/gridReformProblemCount");
}
/**
 *
 * @returns 发现问题区县统计
 */
export function discoverProblemRegionCount() {
  return Get("/v1/applet/statistics/discoverProblemRegionCount");
}

export function regionList() {
  return Get("/v1/applet/regions/regionList");
}
//人员网格围栏
export function singleGridGPS(region_id) {
  return Get("/v1/grids?region_id=" + region_id + "&is_load_gps=1");
}
/**
 * 查询点位列表
 */
export function queryPoinQuestionList(
  is_reform: number,
  page: number,
  point_name: string,
  level3_name: string
) {
  return Get(
    "/v1/applet/statistics/queryPointProblemList?page=" +
      page +
      "&point_name=" +
      point_name +
      "&level3_name=" +
      level3_name +
      "&is_reform=" +
      is_reform
  );
}
export function regionCount(region_id: number) {
  return Get("/v1/applet/regions/regionCount?region_id=" + region_id, {
    loading: true,
  });
}

export function minProgramAuthLogin(code: string) {
  return Post(
    "/v1/minProgramAuthLogin",
    {
      code: code,
    },
    {
      loading: true,
    }
  );
}

export function wxBindingAccount(data: {}) {
  return Post("/v1/bindWechat", data, {
    loading: true,
  });
}

export function securities() {
  return Get("/v1/applet/securities");
}
/**
 * 保障详情
 * @param security
 * @returns
 */
export function securitieDetail(id: number) {
  return Get("/v1/applet/securities/" + id);
}
export function userTodayTrack(userId: number, do_date: string) {
  return Get(
    "/v1/applet/users/userTodayTrack?user_id=" + userId + "&&do_date=" + do_date
  );
}

export function regions(city_id) {
  return Get("/v1/regions?city_id=" + city_id);
}

/**
 * 纠错
 */
export function errorReport(id, data: {}) {
  return Post(`/v1/applet/problems/${id}/errorCorrect`, data, {
    loading: true,
  });
}
